package vista;
import com.toedter.calendar.JDateChooser;

import controlador.ControladorCompraProveedor;

import java.awt.BorderLayout;
import java.awt.event.ActionListener;
import java.util.Date;

import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;

import javax.swing.WindowConstants;
import javax.swing.table.AbstractTableModel;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.TableModel;
import javax.swing.SwingUtilities;


/**
* This code was edited or generated using CloudGarden's Jigloo
* SWT/Swing GUI Builder, which is free for non-commercial
* use. If Jigloo is being used commercially (ie, by a corporation,
* company or business for any purpose whatever) then you
* should purchase a license for each developer using Jigloo.
* Please visit www.cloudgarden.com for details.
* Use of Jigloo implies acceptance of these licensing terms.
* A COMMERCIAL LICENSE HAS NOT BEEN PURCHASED FOR
* THIS MACHINE, SO JIGLOO OR THIS CODE CANNOT BE USED
* LEGALLY FOR ANY CORPORATE OR COMMERCIAL PURPOSE.
*/
public class VentanaListadoDespachosLapsoTiempo extends javax.swing.JFrame {

	{
		//Set Look & Feel
		try {
			javax.swing.UIManager.setLookAndFeel(javax.swing.UIManager.getSystemLookAndFeelClassName());
		} catch(Exception e) {
			e.printStackTrace();
		}
	}

	private JPanel panListadoDespachosLapsosTiempo;
	private JLabel lblFechaInicio;
	private JDateChooser jdFechaInicio;
	private JDateChooser jdFechaFin;
	private JButton btnLimpiar;
	private JButton btnSalir;
	private JButton btnCrearReporte;
	private JTable tblListadoDespachosLapsos;
	private JScrollPane jsListadoDespachosLapsos;
	private JLabel lblFechaFin;

	/**
	* Auto-generated main method to display this JFrame
	*/
	public static void main(String[] args) {
		SwingUtilities.invokeLater(new Runnable() {
			public void run() {
				VentanaListadoDespachosLapsoTiempo inst = new VentanaListadoDespachosLapsoTiempo();
				inst.setLocationRelativeTo(null);
				inst.setVisible(true);
			}
		});
	}
	
	public VentanaListadoDespachosLapsoTiempo() {
		super();
		initGUI();
	}
	
	
	public void mostrarMensaje(String mensaje){
		JOptionPane.showMessageDialog(this, mensaje);
	}
	
	
	public void agregarListener(ActionListener accion){

		btnCrearReporte.addActionListener(accion);
		btnLimpiar.addActionListener(accion);
		btnSalir.addActionListener(accion);
	}

	public void limpiarPantalla(){
		jdFechaFin.setDate(new Date());
		jdFechaInicio.setDate(new Date());
	}
	
	public Date getFechaInicio(){
		return jdFechaInicio.getDate();
	}

	public Date getFechaFin(){
		return jdFechaFin.getDate();
	}

	
	public void setListado(AbstractTableModel abstractTableModel){
		tblListadoDespachosLapsos.setModel(abstractTableModel);
	}
	private void initGUI() {
		try {
			setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
			this.setTitle("Consulta de Despachos por Lapso de Tiempo");
			getContentPane().setLayout(null);
			{
				panListadoDespachosLapsosTiempo = new JPanel();
				getContentPane().add(panListadoDespachosLapsosTiempo, "Center");
				panListadoDespachosLapsosTiempo.setBounds(0, 0, 566, 362);
				panListadoDespachosLapsosTiempo.setLayout(null);
				{
					lblFechaInicio = new JLabel();
					panListadoDespachosLapsosTiempo.add(lblFechaInicio);
					lblFechaInicio.setText("Fecha Inicio:");
					lblFechaInicio.setBounds(58, 42, 93, 15);
				}
				{
					lblFechaFin = new JLabel();
					panListadoDespachosLapsosTiempo.add(lblFechaFin);
					lblFechaFin.setText("Fecha Final:");
					lblFechaFin.setBounds(285, 42, 87, 15);
				}
				{
					jsListadoDespachosLapsos = new JScrollPane();
					panListadoDespachosLapsosTiempo.add(jsListadoDespachosLapsos);
					jsListadoDespachosLapsos.setBounds(58, 154, 450, 115);
					{
						TableModel tblListadoDespachosLapsosModel = 
								new DefaultTableModel(
										new String[][] { { "", "", "", "", "" }, { "", "", "", "", "" } },
										new String[] { "", "", "", "", "" });
						tblListadoDespachosLapsos = new JTable();
						jsListadoDespachosLapsos.setViewportView(tblListadoDespachosLapsos);
						tblListadoDespachosLapsos.setPreferredSize(new java.awt.Dimension(448, 34));
						tblListadoDespachosLapsos.setModel(tblListadoDespachosLapsosModel);
					}
				}
				{
					btnCrearReporte = new JButton();
					panListadoDespachosLapsosTiempo.add(btnCrearReporte);
					btnCrearReporte.setText("Crear Reporte");
					btnCrearReporte.setBounds(136, 95, 141, 22);
				}
				{
					btnSalir = new JButton();
					panListadoDespachosLapsosTiempo.add(btnSalir);
					btnSalir.setText("Salir");
					btnSalir.setBounds(422, 303, 86, 22);
				}
				{
					btnLimpiar = new JButton();
					panListadoDespachosLapsosTiempo.add(btnLimpiar);
					btnLimpiar.setText("Limpiar");
					btnLimpiar.setBounds(297, 95, 88, 22);
				}
				{
					jdFechaInicio = new JDateChooser();
					panListadoDespachosLapsosTiempo.add(jdFechaInicio);
					jdFechaInicio.setBounds(149, 42, 124, 27);
				}
				{
					jdFechaFin = new JDateChooser();
					panListadoDespachosLapsosTiempo.add(jdFechaFin);
					jdFechaFin.setBounds(393, 36, 124, 27);
				}
			}
			pack();
			this.setSize(576, 390);
		} catch (Exception e) {
		    //add your error handling code here
			e.printStackTrace();
		}
	}

}
